#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
装饰器使用
"""

import time

def time_usage(func):
    def wrapper(*args, **kwargs):
        start = time.time()
        func(*args, **kwargs)
        end = time.time()
        used = end - start
        print(f'{func.__name__} used: {used}')

    return wrapper





@time_usage
def one(second):
    time.sleep(second)
    print(111)

@time_usage
def two(second):
    time.sleep(second)
    print(222)


def add(num1, num2):
    return num1 + num2

if __name__ == '__main__':
    second = 3
    one(second)
    second = 5
    two(second)

    num1, num2 = 1, 2
    add(num1, num2)







